import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

class LinkPage extends StatefulWidget {
  const LinkPage({Key? key}) : super(key: key);

  @override
  State<LinkPage> createState() => _LinkPageState();
}

class _LinkPageState extends State<LinkPage> {
  final List<Map<String, dynamic>> items = [
    {
      "title": "我不要做复制品",
      "author": "守蜂乐的羊",
      "image": "lib/assets/logo.png",
      "likes": 443,
    },
    {
      "title": "《断层：破碎世界》剧组招募！！",
      "author": "bbziper",
      "image": "lib/assets/logo.png",
      "likes": 248,
    },
    {
      "title": "『GLOOMY』整点缝合线吃吃",
      "author": "久上疫_精神状态是会随地咬人的那种",
      "image": "lib/assets/logo.png",
      "likes": 165,
    },
    {
      "title": "Rose, Rose🌺",
      "author": "寒博入殓师Orange_发疯创人版",
      "image": "lib/assets/logo.png",
      "likes": 167,
    },
    {
      "title": "《儿童绘本》时间糖果奇遇记（上）",
      "author": "作者名",
      "image": "lib/assets/logo.png",
      "likes": 100,
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          '排行榜',
          style: TextStyle(color: Colors.black),
        ),
        actions: [
          IconButton(
            icon: const Icon(Icons.search),
            onPressed: () {
              Navigator.pushNamed(context, '/search');
            },
          ),
          IconButton(
            icon: const Icon(Icons.notifications),
            onPressed: () {},
          ),
        ],
      ),
      body: Stack(
        children: [
          Positioned(
            top: 10,
            right: 10,
            child: Image.asset(
              'lib/assets/logo.png',
              width: 50,
              height: 50,
            ),
          ),
          ListView.builder(
            itemCount: items.length,
            itemBuilder: (context, index) {
              final item = items[index];
              return Padding(
                padding: const EdgeInsets.all(8.0),
                child: Card(
                  child: Column(
                    children: [
                      Image.asset(
                        item['image'],
                        height: 200,
                        width: double.infinity,
                        fit: BoxFit.cover,
                      ),
                      ListTile(
                        title: Text(item['title']),
                        subtitle: Text(item['author']),
                        trailing: Column(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            Icon(Icons.favorite, color: Colors.red),
                            Text('${item['likes']}'),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}
